package config_manager

import (
	"github.com/golang/protobuf/proto"
	"go_server/game_server/dataconfig/configpb"
	"go_server/game_server/util"
	"go_server/zinx/zlog"
)

var (
	stcTable_property_Sheet_property map[int32]*configpb.StcTableProperty_SheetProperty_D7B0CE46
)

func load_StcTableProperty_SheetProperty(fileName string) {
	fullPath := configFilePath + fileName
	content := util.GetReadFileBuf(fullPath)

	zlog.Debug("load_StcTableProperty_SheetProperty start!!!")
	msg := &configpb.DataSet_StcTableProperty_SheetProperty_D7B0CE46{}
	proto.Unmarshal(content, msg)

	stcTable_property_Sheet_property = make(map[int32]*configpb.StcTableProperty_SheetProperty_D7B0CE46)

	for _, info := range msg.Items {
		stcTable_property_Sheet_property[info.Id] = info
	}
	zlog.Debug("load_StcTableProperty_SheetProperty complete!!!")
}

func GetConfigStcTableProperty_SheetProperty(id int32) (configpb.StcTableProperty_SheetProperty_D7B0CE46, bool) {
	config, ok := stcTable_property_Sheet_property[id]
	if !ok {
		zlog.Errorf("GetConfigStcTableProperty_SheetProperty Err!!! id: %d", id)
		return configpb.StcTableProperty_SheetProperty_D7B0CE46{}, false
	}
	return configpb.StcTableProperty_SheetProperty_D7B0CE46{
		Id:           config.Id,
		Abbreviation: config.Abbreviation,
		Power:        config.Power,
		Power1:       config.Power1,
	}, true
}
